package force;

import assembly.Mass;
import java.util.Scanner;
import simulation.ILoadable;
import simulation.ITogglable;
import simulation.Model;
import util.Vector;


/**
 * Abstraction of forces.
 * 
 * @author Dagbedji Fagnisse
 * @author Scott Valentine
 * 
 */

public abstract class Force implements ITogglable, ILoadable {
    private boolean myToggleOn;

    /**
     * Compute the value of the force on a specific mass object.
     * 
     * @param m mass to apply this force to
     * @return a vector that represents the force on the given mass
     */
    public abstract Vector getForceOn (Mass m);

    /**
     * gives the state of the force (on or off)
     * 
     * @return the status of the force (on or off)
     */
    public boolean isForceOn () {
        return myToggleOn;
    }

    /**
     * toggle the force between off and on
     */
    public void toggle () {
        myToggleOn = !myToggleOn;
    }

    /**
     * returns the key that toggles this force
     * 
     * @return the toggle key
     */
    public abstract int getToggleKey ();

    @Override
    public ILoadable load (Scanner line, Object o) {
        return load(line, (Model) o);
    }

    /**
     * @param line current line of read-in file
     * @param model has the force added to it
     */
    public abstract Force load (Scanner line, Model model);

}
